package com.c8a.validation.controller;

import com.c8a.validation.entity.Employee;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.groups.Default;

/**
 * 分组校验
 * @Author C8A
 * @Date 2022-04-23 21:36
 * @Email 1912327276@qq.com
 */

@RestController
public class EmployeeController {
    /**
     *
     * 测试分组校验
     *
     * {
     *     "id": 1,
     *     "name": "Query",
     *     "studentVO": {
     *         "students": [
     *             {
     *                 "id": 1,
     *                 "name": "eddie",
     *                 "title": "初级开发工程师",
     *                 "age": 22,
     *                 "email": "23123@qq.com"
     *             },
     *             {
     *                 "id": 2,
     *                 "name": "jack",
     *                 "title": "初级顾问",
     *                 "age": 26,
     *                 "email": "231223@qq.com"
     *             }
     *         ]
     *     }
     * }
     *
     * @param employee
     * @return
     */
    @PostMapping("/valid6")
    public ResponseEntity<Employee> valid6(@RequestBody @Validated(value = {Employee.Add.class, Default.class}) Employee employee) {
        return ResponseEntity.ok(employee);
    }
}
